<?php
use yii\helpers\Url;
$catname = Yii::$app->params['cat_name'];
$authorname = Yii::$app->params['author_name'];
$statusname = Yii::$app->params['status_name'];

$this->params['breadcrumbs']['/admin-news.html'] = '管理';
$this->params['breadcrumbs']['active'] = '文章发布';
$this->title = "文章发布" . Yii::$app->params['blogEtc'];
?>

<form action="" method="POST">
	<input name="_csrf" type="hidden" id="_csrf" value="<?= Yii::$app->request->csrfToken ?>">
	<input name="title" placeholder="标题" value="<?=$data['title']?>" type="text"></input>
	<select name="cid">
		<?php foreach ($catname as $k => $v): ?>
			<option <?=$data['catid'] == $k?'selected="selected"':''?> value="<?=$k?>"><?=$v['text']?></option>
		<?php endforeach ?>
	</select>
	<select name="author_id">
		<?php foreach ($authorname as $k => $v): ?>
			<option <?=$data['author_id'] == $k?'selected="selected"':''?> value="<?=$k?>"><?=$v['text']?></option>
		<?php endforeach ?>
	</select>
	<select name="status">
		<?php foreach ($statusname as $k => $v): ?>
			<option <?=$data['status'] == $k?'selected="selected"':''?> value="<?=$k?>"><?=$v?></option>
		<?php endforeach ?>
	</select>
	<input name="slug" placeholder="seo链接" value="<?=$data['slug']?>" type="text"></input>
	<input name="sn" placeholder="序号" value="<?=$data['sn']?>" type="number"></input>
	<label><input name="hot" type="checkbox" <?=$data['hot']?'checked="checked"':''?>></input>热门？</label>
	<label><input name="pl" type="checkbox" <?=$data['allow_comment']?'checked="checked"':''?>></input>允许评论？</label>

	<br />
	<script id="editor" type="text/plain" style="width:1024px;height:500px;"><?=$data['describe']?></script>
	<br />
	<button onclick = 'getLastSave()' type="button">加载最后保存代码</button>
	<input value="提交" type="submit"></input>
</form>
<script type="text/javascript" charset="utf-8" src="/assets/ueditor/ueditor.config.js"></script>
<script type="text/javascript" charset="utf-8" src="/assets/ueditor/ueditor.all.min.js"> </script>

<link rel="stylesheet" type="text/css" href="/assets/ueditor/third-party/SyntaxHighlighter/shCoreDefault.css">
<script type="text/javascript">
	var URL = '<?=Yii::$app->params['siteUrl']?>';
    var ue = UE.getEditor('editor',{
    	textarea : 'describe',
    	maximumWords : 5000, //允许最大字数
    });
    function getLastSave() {
		ue.execCommand('drafts');
	}
</script>